<?php
$isReloadable = true;
require_once("../../pers/inc.config.php");
require_once(OVF_FS_WEB_ROOT.'/app/_inc/inc.session.php');
require_once(OVF_FS_WEB_ROOT.'/app/_inc/funct.html.php');

$objSess->setReqSV('agenda', 'vistaAge', 'Sett');
$objSess->setReqSV('agenda', 'dataAge', date('d/m/Y'));

$objSess->setReqSV('agenda', 'listAge', $objSess->idUtente);
$sListaAgende = $objSess->getSV('agenda','listAge');
if ($sListaAgende=='') {
	$sListaAgende = $objSess->aSV['agenda']['listAge'] = $objSess->idUtente;
}
$sListaNomiAgende = "";
$sSql = "SELECT CONCAT(nome,' ',cognome) AS nominativo FROM ovf_utenti "
	." WHERE id_utente IN ($sListaAgende) ORDER BY cognome,nome";
$objDB->query($sSql,'selListAge');
while($acLA = $objDB->fetch('selListAge')) {
	$sListaNomiAgende .= $acLA['nominativo'].", ";
}
$sListaNomiAgende = substr($sListaNomiAgende,0,-2);
$msgPag = "<div class='txt1' style='text-align:left;font-weight:normal;'>"._t("Stai visualizzando l'agenda di")
.": <b>".$sListaNomiAgende."</b></div>".$msgPag;

$objSess->setReqSV('agenda', 'viewMemo', 'S');
$sViewMemo = $objSess->getSV('agenda','viewMemo');
if ($sViewMemo=='') {
	$sViewMemo = $objSess->aSV['agenda']['viewMemo'] = 'all';
}
if ($sViewMemo=='N') {
	$msgPag = "<div class='txt1' style='text-align:left;font-weight:normal;'>"._t("Visualizzazione MEMO")
	.": <b>"._t("disabilitata")."</b></div>".$msgPag;
}

$objSess->setReqSV('agenda', 'listTI', 'all');
$sListaTI = $objSess->getSV('agenda','listTI');
if ($sListaTI=='') {
	$sListaTI = $objSess->aSV['agenda']['listTI'] = 'all';
}
if ($sListaTI[0]!='a') {
   if ($sListaTI=='0') {
      $msgPag = "<div class='txt1' style='text-align:left;font-weight:normal;'>"._t("Stai visualizzando solo")
      ." <b>MEMO</b></div>".$msgPag;
   } else {
   	$sListaNomiTI = "";
   	$sSql = "SELECT descr FROM ovf_agenda_tipi_imp "
   		." WHERE id_tipo_imp IN ($sListaTI) ORDER BY descr";
   	$objDB->query($sSql,'selListAge');
   	while($acLA = $objDB->fetch('selListAge')) {
   		$sListaNomiTI .= $acLA['descr'].", ";
   	}
   	$sListaNomiTI = substr($sListaNomiTI,0,-2);   	
   	$msgPag = "<div class='txt1' style='text-align:left;font-weight:normal;'>"._t("Stai visualizzando solo")
   	.": <b>".$sListaNomiTI."</b></div>".$msgPag;
   }
}

$oDataAge = new ovfDate();
if (reqVarStr2date('dataAge')===false) {
   $msgPag .= "data agenda errata<br>";
} else {
   $oDataAge = new ovfDate(reqVar('dataAge'));
   $_REQUEST['dataAge'] = $oDataAge->getDMY();
}

require "agen".reqVar('vistaAge').".php";